import {service} from "@/api/index";

function getPost(id) {
    return service.get("/TbPost/"+id)
}
function getPosts(current,size,total) {
    return service.get(`/TbPost/getList/${current}/${size}/${total}`)
}
function getQueryPosts(current,size,total,query) {
    if (query===''||query===null||query===undefined){
        return this.getPosts(current,size,total)
    }
    return service.get(`/TbPost/getListSearch/${current}/${size}/${total}/${query}`)
}

function getPostsById(id,current,size,total) {
    return service.get(`/TbPost/getList/${id}/${current}/${size}/${total}`)
}
function delPost(id) {
    return service.delete("/TbPost/"+id)
}

function editPost(data) {
    return service.put("/TbPost/"+data.id,data)
}function addPost(data) {
    return service.post("/TbPost",data)
}

export default {
    delPost,
    editPost,
    getQueryPosts,
    addPost,
    getPost,
    getPosts,
    getPostsById,
}
